﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using Frame.Lib.Core.Tree;
using Frame.Lib.Utilities;

public partial class Common_MoveTree : PageSelectTree
{
    private TreeBO<TreeInfo> _tree;

    private string TableName
    {
        get
        {
            return Request["TableName"];
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        _tree = new TreeBO<TreeInfo>(TableName);
        if (!IsPostBack)
        {
            if (Request["Title"] != null)
            {
                lblTitle.Text = Request["Title"];
            }
            BindTree();
        }
        tvList.Attributes.Add("onclick", "SingleSelect()");
       
    }

    private void BindTree()
    {
        
        _tree.BindTreeView(tvList, true, null);
        tvList.ExpandAll();
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        string strSelectIDs = Request["SelectIDs"];
        List<int> lstSelectIDs = StrUtil.SplitToInt(strSelectIDs);

        List<int> lstDirIDs = StrUtil.SplitToInt(CheckedIDs);
        if (lstDirIDs.Count > 0)
        {
            int destIDs = lstDirIDs.First();
            if (_tree.Include(lstSelectIDs, destIDs))
            {
                JSUtil.Alert("目标目录不得包括自己及子目录");
                BindTree();
                return;
            }
            _tree.Move(lstSelectIDs, destIDs);
        }
        JSUtil.ResponseJS("close();returnValue=true");
    }   
}
